package com.bocloud.cmp.entity.resource;

import java.util.Date;
import java.util.List;

import org.springframework.format.annotation.DateTimeFormat;

import com.bocloud.common.utils.DateSerializer;
import com.bocloud.entity.annotations.Column;
import com.bocloud.entity.annotations.IgnoreAll;
import com.bocloud.entity.annotations.PK;
import com.bocloud.entity.annotations.Table;
import com.bocloud.entity.bean.GenericEntity;
import com.bocloud.entity.meta.PKStrategy;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

@Table("cluster")
public class Cluster extends GenericEntity {

	@PK(value = PKStrategy.AUTO)
	private Long id;
	@Column("uuid")
	private String uuid;
	@Column("vendor_id")
	private Long vendorId; // 云供应商ID
	@IgnoreAll
	private String vendorName; // 云供应商名称
	@Column("gmt_expired")
	@JsonSerialize(using = DateSerializer.class)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date gmtExpired;// 过期时间
	@Column("cpu_total")
	private Long cpuTotal;
	@Column("mem_total")
	private Long memTotal;
	@Column("disk_total")
	private Long diskTotal;
	@Column("cpu_used")
	private Long cpuUsed;
	@Column("mem_used")
	private Long memUsed;
	@Column("disk_used")
	private Long diskUsed;
	@Column("vdc_id")
	private Long vdcId;
	@Column("category")
	private String category;
	@IgnoreAll
	private List<HostSystem> hosts;
	@IgnoreAll
	private String vdcName;
	@Column("host_num")
	private Integer hostNum;// 集群下物理主机数量
	@Column("vm_num")
	private Integer vmNum;// 集群下虚拟机数量
	@Column("template_num")
	private Integer templateNum;// 集群下模板数量
	@Column("cpu_core")
	private Integer cpuCore;// 集群中cpu核数
	@Column("cluster_val")
	private String clusterVal;

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the uuid
	 */
	public String getUuid() {
		return uuid;
	}

	/**
	 * @param uuid
	 *            the uuid to set
	 */
	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	/**
	 * @return the vendorId
	 */
	public Long getVendorId() {
		return vendorId;
	}

	/**
	 * @param vendorId
	 *            the vendorId to set
	 */
	public void setVendorId(Long vendorId) {
		this.vendorId = vendorId;
	}

	/**
	 * @return the vendorName
	 */
	public String getVendorName() {
		return vendorName;
	}

	/**
	 * @param vendorName
	 *            the vendorName to set
	 */
	public void setVendorName(String vendorName) {
		this.vendorName = vendorName;
	}

	/**
	 * @return the gmtExpired
	 */
	public Date getGmtExpired() {
		return gmtExpired;
	}

	/**
	 * @param gmtExpired
	 *            the gmtExpired to set
	 */
	public void setGmtExpired(Date gmtExpired) {
		this.gmtExpired = gmtExpired;
	}

	/**
	 * @return the cpuTotal
	 */
	public Long getCpuTotal() {
		return cpuTotal;
	}

	/**
	 * @param cpuTotal
	 *            the cpuTotal to set
	 */
	public void setCpuTotal(Long cpuTotal) {
		this.cpuTotal = cpuTotal;
	}

	/**
	 * @return the memTotal
	 */
	public Long getMemTotal() {
		return memTotal;
	}

	/**
	 * @param memTotal
	 *            the memTotal to set
	 */
	public void setMemTotal(Long memTotal) {
		this.memTotal = memTotal;
	}

	/**
	 * @return the diskTotal
	 */
	public Long getDiskTotal() {
		return diskTotal;
	}

	/**
	 * @param diskTotal
	 *            the diskTotal to set
	 */
	public void setDiskTotal(Long diskTotal) {
		this.diskTotal = diskTotal;
	}

	/**
	 * @return the cpuUsed
	 */
	public Long getCpuUsed() {
		return cpuUsed;
	}

	/**
	 * @param cpuUsed
	 *            the cpuUsed to set
	 */
	public void setCpuUsed(Long cpuUsed) {
		this.cpuUsed = cpuUsed;
	}

	/**
	 * @return the memUsed
	 */
	public Long getMemUsed() {
		return memUsed;
	}

	/**
	 * @param memUsed
	 *            the memUsed to set
	 */
	public void setMemUsed(Long memUsed) {
		this.memUsed = memUsed;
	}

	/**
	 * @return the diskUsed
	 */
	public Long getDiskUsed() {
		return diskUsed;
	}

	/**
	 * @param diskUsed
	 *            the diskUsed to set
	 */
	public void setDiskUsed(Long diskUsed) {
		this.diskUsed = diskUsed;
	}

	/**
	 * @return the vdcId
	 */
	public Long getVdcId() {
		return vdcId;
	}

	/**
	 * @param vdcId
	 *            the vdcId to set
	 */
	public void setVdcId(Long vdcId) {
		this.vdcId = vdcId;
	}

	/**
	 * @return the category
	 */
	public String getCategory() {
		return category;
	}

	/**
	 * @param category
	 *            the category to set
	 */
	public void setCategory(String category) {
		this.category = category;
	}

	/**
	 * @return the hosts
	 */
	public List<HostSystem> getHosts() {
		return hosts;
	}

	/**
	 * @param hosts
	 *            the hosts to set
	 */
	public void setHosts(List<HostSystem> hosts) {
		this.hosts = hosts;
	}

	/**
	 * @return the vdcName
	 */
	public String getVdcName() {
		return vdcName;
	}

	/**
	 * @param vdcName
	 *            the vdcName to set
	 */
	public void setVdcName(String vdcName) {
		this.vdcName = vdcName;
	}

	/**
	 * @return the hostNum
	 */
	public Integer getHostNum() {
		return hostNum;
	}

	/**
	 * @param hostNum
	 *            the hostNum to set
	 */
	public void setHostNum(Integer hostNum) {
		this.hostNum = hostNum;
	}

	/**
	 * @return the vmNum
	 */
	public Integer getVmNum() {
		return vmNum;
	}

	/**
	 * @param vmNum
	 *            the vmNum to set
	 */
	public void setVmNum(Integer vmNum) {
		this.vmNum = vmNum;
	}

	/**
	 * @return the templateNum
	 */
	public Integer getTemplateNum() {
		return templateNum;
	}

	/**
	 * @param templateNum
	 *            the templateNum to set
	 */
	public void setTemplateNum(Integer templateNum) {
		this.templateNum = templateNum;
	}

	/**
	 * @return the cpuCore
	 */
	public Integer getCpuCore() {
		return cpuCore;
	}

	/**
	 * @param cpuCore
	 *            the cpuCore to set
	 */
	public void setCpuCore(Integer cpuCore) {
		this.cpuCore = cpuCore;
	}

	/**
	 * @return the clusterVal
	 */
	public String getClusterVal() {
		return clusterVal;
	}

	/**
	 * @param clusterVal
	 *            the clusterVal to set
	 */
	public void setClusterVal(String clusterVal) {
		this.clusterVal = clusterVal;
	}

	/**
	 * @param createrId
	 * @param ownerId
	 * @param menderId
	 * @param id
	 * @param uuid
	 * @param vendorId
	 * @param vendorName
	 * @param gmtExpired
	 * @param cpuTotal
	 * @param memTotal
	 * @param diskTotal
	 * @param cpuUsed
	 * @param memUsed
	 * @param diskUsed
	 */
	public Cluster(Long createrId, Long ownerId, Long menderId, Long id, String uuid, Long vendorId, String vendorName,
			Date gmtExpired, Long cpuTotal, Long memTotal, Long diskTotal, Long cpuUsed, Long memUsed, Long diskUsed,
			Integer hostNum, Integer vmNum, Integer templateNum, Integer cpuCore, String clusterVal) {
		super(createrId, ownerId, menderId);
		this.id = id;
		this.uuid = uuid;
		this.vendorId = vendorId;
		this.vendorName = vendorName;
		this.gmtExpired = gmtExpired;
		this.cpuTotal = cpuTotal;
		this.memTotal = memTotal;
		this.diskTotal = diskTotal;
		this.cpuUsed = cpuUsed;
		this.memUsed = memUsed;
		this.diskUsed = diskUsed;
		this.hostNum = hostNum;
		this.vmNum = vmNum;
		this.templateNum = templateNum;
		this.cpuCore = cpuCore;
		this.clusterVal = clusterVal;
	}

	/**
	 * 
	 */
	public Cluster() {
		super();
	}

	/**
	 * @param createrId
	 * @param ownerId
	 * @param menderId
	 * @param name
	 * @param status
	 * @param deleted
	 * @param props
	 * @param remark
	 */
	public Cluster(Long createrId, Long ownerId, Long menderId, String name, String status, Boolean deleted,
			String props, String remark) {
		super(createrId, ownerId, menderId, name, status, deleted, props, remark);
	}

	public Cluster(Long createrId, Long ownerId, Long menderId) {
		super(createrId, ownerId, menderId);
	}

	public void preSave(Long createrId, Long menderId, Long vendorId, Long vdcId) {
		this.setCreaterId(createrId);
		this.setMenderId(menderId);
		this.setVendorId(vendorId);
		this.setVdcId(vdcId);
	}

}
